using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace iOSForLife.Data.Models;

public class UserModel
{
    [Column(TypeName = "varchar(50)")] public string UserName { get; set; } = "";

    [Key]
    [Column(TypeName = "varchar(10)")]
    public string UserId { get; set; } = "";

    [Column(TypeName = "varchar(2)")] public string Gender { get; set; } = "";
    [Column(TypeName = "varchar(20)")] public string ClassName { get; set; } = "";
    [Column(TypeName = "varchar(11)")] public string PhoneNum { get; set; } = "";

    /// <summary>
    /// Founder : 创始人
    /// President : 社长,团支书,秘书长
    /// Minister : 部长
    /// Department : 部员成员
    /// Member : 普通成员
    /// </summary>
    [Column(TypeName = "varchar(20)")]
    public string Identity { get; set; } = "Member";

    public List<TodoModel> Todos { get; set; } = [];
    public List<ClipboardModel> Clipboard { get; set; } = [];

    public UserDataModel UserData { get; set; } = new();
}

[Serializable]
public class ClipboardModel : DataModel
{
    [Key]
    [Column(TypeName = "varchar(32)")]
    public string Id { get; set; } = "";

    [Column(TypeName = "varchar(1024)")] public string Content { get; set; } = "";

    [Column(TypeName = "varchar(32)")] public string UserId { get; set; } = "";

    [Column(TypeName = "varchar(32)")] public string UpdateTime { get; set; } = "";

    public void Update(ClipboardModel model)
    {
        if (!string.IsNullOrEmpty(model.Content)) Content = model.Content;
        if (!string.IsNullOrEmpty(model.UpdateTime)) UpdateTime = model.UpdateTime;
    }
}